use axum::Json;
use serde::Serialize;

#[derive(Serialize, Debug, Default)]
pub struct Idea {
    id: usize,
    title: String,
    content: String,
    tags: Vec<String>,
    stars: usize,
}

#[derive(Serialize, Debug, Default)]
pub struct IdeaBrief {
    id: usize,
    title: String,
    content: String,
}

#[derive(Serialize, Debug, Default)]
pub struct IdeasBrief {
    index: usize,
    count: usize,
    ideas_brief: Vec<IdeaBrief>,
}

pub async fn get_idea(id: usize) -> Idea {
    dbg!("Getting idea: {}", id);

    Idea {
        id,
        title: "Title".to_owned(),
        content: "Content".to_owned(),
        tags: vec!["tag1".to_owned(), "tag2".to_owned()],
        stars: 10,
    }
}

pub async fn get_ideas_brief() -> Result<Json<IdeasBrief>, String> {
    dbg!("Getting ideas brief");

    Ok(Json(IdeasBrief {
        index: 0,
        count: 5,
        ideas_brief: vec![
            IdeaBrief {
                id: 1,
                title: "Title 1".to_owned(),
                content: "Content 1".to_owned(),
            },
            IdeaBrief {
                id: 2,
                title: "Title 2".to_owned(),
                content: "Content 2".to_owned(),
            },
            IdeaBrief {
                id: 3,
                title: "Title 3".to_owned(),
                content: "Content 3".to_owned(),
            },
            IdeaBrief {
                id: 4,
                title: "Title 4".to_owned(),
                content: "Content 4".to_owned(),
            },
            IdeaBrief {
                id: 5,
                title: "Title 5".to_owned(),
                content: "Content 5".to_owned(),
            },
        ],
    }))
}